refined controller code