pattern matching bugfix, empty pattern sometime happens