Update to take function instead of object