added crossing point sorting