Moved up check to see if 'repo' was valid before calling the lower() method on it.