Refactor index.php