extracted login check,. now checking when loading the page instead.