Chaining function interview question