Refactored code to treat builtin functions like user defined functions