added things to redirect users to main page if they are not logged in.