Separated out script fetching logic

Created a file for fetching a metadata script
Removed dead code and made style consistency