optimized collision check