fix Router algorithm