added all prototypes, added sql functions