Fix: factory should be called only one time depending on the environment