Moved echo json to end