refactoring + canEat funtion