refactored mastermind