wrote pattern matching script