updated controller logic