refactor panDetected