minor detection algorithm optimizations