pages controller code cleanup