refine code about user defining