generalizing the diagonal logic