working add and update functionality