Bug fix for add and update