contrib: reduce unnecessary duplication of code