Fixed a bug with EngineState check