completed basic formatting script
abstracted common code elements into parent script