Optimize collision checking