move duplicate code to a mixin class