Modified Login function