bug fixing on JSON update and insert