Update index.php

Convert previous version to be a class