Separated core functionality for each script into a separate module for reusability.