json writer logic added