minor bug with json and refactoring