Refactor envelope model