code for autooperatio of p3dx.