This logic exists 5 times! Sounds like it needs to be a function that's reusable to me.