changed algorithm to work on 2D array

looks less glitchy but very cool