implement full login function