refactored code- parametrized delimiter