collect common code