fixed algorithm again, added mouse avoidance