updated diagonals check logic