Login logic improvements