Cleaning up the main script into a utility class