added insert logic