Refactor calcNextWpDir