added function to insert results