Added 'perfect' envelope logic