Changed the interfacing API to accept a function