doing json decoding properly
and removing the recursion that @ayakushev99 pointed out