added patterns, reworked bounds checking though its n^2