Puzzle logic done