refactored scripts