refactored common fn building into seperate private function make_fn/2