Remove duplicated code from some controllers