improving movement handlers, handling map edge cases