added some db functions and edited schema