Added database functions
Constructed main