New collision code (looks ugly)