reduced duplication by extracting a superclass