fixed some db insertion issues