moving common code to parent class