loadJSON method and refactoring