move legal profile db code to the engine