remove unused code
Refactor out file merge function