Reduce duplication of code