if login failed, `result` will be `nil`, causing failures down the road.  This also modifies the outer scope's `result`, which may not be a problem in this case, but is very bad practice.