a first implementatin of a pattern detection