add helper method for locality and split out ranking logic