refactored integration script