Rewrote check for patterns