Factor common location code into a method