login function is almost finished.