refactored the json api a bit