modified controller logic