Generalize slightly

Signed-off-by: Ricky Elrod <ricky@elrod.me>
refactor this to be less annoying and repetative

Signed-off-by: Ricky Elrod <ricky@elrod.me>