Fixed needlessly complicated code. Now directly checks arrays.(Bug fix)