added insert and update function