fixed most of main.php