updated 3.2.3 code, based on work with Nada