Move common functions to an abstract class