add two end statements into the controller