Fixed a bug when checking the diagonals.