Related files algorithem