improving function chaining