Fixing controller logic