Pattern match bug fix