modularize the script