8-puzzle + refactoring