added new function to insert record to db