fixed bug in db insertion