Move common code to an abstract class