apply: code and function refine;