Refactored code for custom delimiter