fix counter, refactor index.php