refactor the local  fn to be accessible from other methods, reducing duplicate code; adds comment