improved collision code a bit