Refractoring of function chaining