cleaning up code in controllers