Refactoring auxiliary functions for basic string iteraotr.