Refactored the scripts to fit my needs