custom functions return json instead of an object