err should be null if there are no errors