refactor map pattern occurences code