refactoring of delimiter detection