controller code cleanup