Added isMainRoute algorithm.