added sql functions