fixed issue where the JSON result would sometimes be prematurely out of scope