refactored: copy files to build tree - use a function