Pages field check if selected page exists

On my “Article” template I have an Author. A team member of the “Team” page can be selected via a pages field. Now I like to check if the field is not empty:

<?php if($page->author()->isNotEmpty()) : ?>
<?= $page->author()->toPage()->title(); ?>
<?php endif ?>

The problem is, when the author is deleted it still thinks it has content. So how can I check if the toPage exists in stead of checking if the field is empty?

I think I fixed it myself

<?php if($author = $page->author()->toPage()) : ?>
<?= $author->title(); ?>
<?php endif ?>