remove unnecessary patterns