Refactored script_builder