fixed loading main page logic