fix movement over boundaries