Code refactor for Excel