Added utility function to check movement direction