With some refactoring and more accurate gameplay logic