Moved login to a model