Added function to insert data into database