Refactored tooltip movement algorithm to be more precise