refactored 3D inflation code