refactor script to consolidate usage