refactor move grab_sources() function code to main()