add functioning loop to index.php