Improved collision check algorithm