refactor direction from mouse