pattern match and index added