Refactor WordLadder