better hovering algorithm