added login guard function