updated the capture script
edited issue with cleanup