Refactored scripts to use arrays