Update cmx_core.php

refactor code