working template script with replacement and execute