optimized a little bit. removed clone2Dmatrix it's only used to determine cycles. used a path 2darray that's only created once