Add custom attr and optimize code.