added functions to index.php so that we can generalize the function kind of :P