updated controller code