Separate script into smaller, more focused files