Login function fixed