added logic to detect pattern instead of assuming a pre-parsed file