updated the code to insert query