code cleanup for nested json api