added experimental loop in main to find all occurrences of a pattern