Refactored scripts to ensure working instance