Refactor controller with respond_to.