Automatically determines number of steps