fixed login function