Updated to utilize prebuild sql functions in the db object
Updated code to fix failing tests after refactor