optimization and re-structure code for CustParams method