separated offline functions into a factory