moved error reporting code out of index.php