Remove duplicate code by using inheritance