Game logic not working correctly