refactoring to work with actual JSON format