refactor Mastermind