Added check on isloggedin()