refactored json parsing to a more useful way