function to insert data