code refacotring in index.php