pass in the function as well as the key