fixing the db related functions