Understanding and guiding the phase inversion process for synthesis of solvent resistant nanofiltration membranes