Simple patch for custom function

Needs more tests