refactoring code, to add a new way to solve the puzzles, and to clean up