fix out of range bug in stepsize