since ```err`` does not need to last beyond the ```if``` statement, declaring it inline would be more idiomatic