Updated controller logic