changed the json output format from an object to an array, which compresses the output by approx 40%
small code rearrangement