Refactored code to accept many delimiters of multiple length