Fix getBeforeAndAfterNamesAbsolute algorithm to deal some names correctly