This initially seems like a lot of duplication. Would you consider to refactor it?