Improved controller logic