Fixed some scoping issues with functions/procedures and generated error
when function is called but not found
fixing merge issue
test