Reduce code duplication by using inheritance