optimize code and use chain system to call methods