refactor to take a function param, etc.