Changed way to determine if movement is ended