Refine the code for surface multiple level grading