fix pattern bugs