for (int j = 0; j <= count(steps); j++) How many elements in "steps"? How many times around that loop?
for (int j = 0; j <= count(steps); j++)