refactored how to read JSON