Replaced ['0'] through [0] everywhere in code.
Changed order of criteria to check.