finishing code for inserting