Make multiple pages and set template/content on theme activation?

There might be a better way to do this, but after testing and testing I have found out how to get the code to work 🙂

So this code will make as many pages as needed, set different content for each page and set a different template if needed.

I am not the best at coding php, so there might be a better way to do this but it works (after hours of testing)

if (isset($_GET['activated']) && is_admin()){
    add_action('init', 'create_initial_pages');
}
function create_initial_pages() {

    $pages = array( 
         // Page Title and URL (a blank space will end up becomeing a dash "-")
        'Services' => array(
            // Page Content     // Template to use (if left blank the default template will be used)
            'Services Content'=>'page-bottom-sidebar.php'),

        'Prices' => array(
            'Prices Content'=>'page-wide.php'),

        'F A Q' => array(
            'FAQ Content'=>' '),
    );

    foreach($pages as $page_url_title => $page_meta) {

        $id = get_page_by_title($page_url_title);

        foreach ($page_meta as $page_content=>$page_template){

            $page = array(
                'post_type'   => 'page',
                'post_title'  => $page_url_title,
                'post_name'   => $page_url_title,
                'post_status' => 'publish',
                'post_content' => $page_content,
                'post_author' => 1,
                'post_parent' => ''
            );

            if(!isset($id->ID)){
                $new_page_id = wp_insert_post($page);
                if(!empty($page_template)){
                    update_post_meta($new_page_id, '_wp_page_template', $page_template);
                }
            }
        }
    }
}

Well I hope it helps someone out there!