Added comments, change echo json to return json