added repeated patterns to logic