Worked a bit on the checkState function