Refactoring, added code to handle two delimiters