Refactored index.php after fixing server permission issues