Optimized if/else block in illusion filter