fixed a serious bug on the engine