combine some repeated code

Not an essential change, but I think it's an improvement.
Think this might be a typo...