making sure to return function object
Merge pull request #2315 from beatak/avoid_poltergeist_error

making sure to return function object