fixed script for headless execution