guessing game - code refactoring