Modified code for Controller