changed sql functions