moved link_files function to top. derp