Problem with if statement controlling 8x8 matrix