code refactor for expansion