added error checking to index.php