clean up controller code