I suppose I could have an if-else which tries to reduce the duplication. Let me try.