edited controller to return json response