Difficulty levels algorithm implementation, some refactoring