Fixed bug in engine.py