refactoring login form, fix redirect after login