implement insert, update functionality