How to limit WordPress pages during updates?

Here is a little snipit of code that I used for my site while it was under construction

<?php
/* ROUGH METHOD OF DENY ACCESS */
    $underconstruct = array(121, 46, 124, 97);
    if(!is_user_logged_in() && !in_array(get_the_ID(), $underconstruct)) {
        wp_redirect(get_permalink(121));
        exit();
    }
?>

I put this at the top of my header.php.
the $underconstruct array is the page/post ids that all not logged in users can see. If they are not logged in and are not on one of the pages that they should be, they get redirected. If the user is logged in, then everything will proceed as normal.