refactor pan detected method