error with insert function corrected