refactoring pacman