Login function somewhat working