fixed undefined for length on json object