now only logs in if necessary