refactored regex and comments