adjusted code to work with 6 and 9 piece puzzles