index.php refactoring