fixing controller logic