modify EM framework by adding layer refine