edited hmg_engine.c