Would not i be possible to refactor this? There is a lot of repetition.