Refactor main function and source vars differently