improve code for apu envelope unit.