refactoring and labyrinth controller