Fixed bug in functionExists function