More efficient movement function