fixed typo
tweaked json_encode call to ease debugging