Refactor envy files code