revise the messy code in index.php (views)