Refactor implementation of files expansion