restructuring mongodb embedd script completely