Fixing login function