refactored index.php to be a little more object oriented