Fixed error in movement detection