Recommend introducing the checkmate package here as it will save a lot of hassle. https://mllg.github.io/checkmate/articles/checkmate.html