Trying to Modify CallOut script

I have been attempting to modify the outbound script found to do a slightly different path.

What I have is:

exten => s,1,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
exten => s,2,Set(TIMEOUT(response)=40) ; Set Response Timeout to 10 seconds
exten => s,3,Answer
exten => s,4,Wait(1)
exten => s,5,Background(outboundmsgs/msg1) ; "play outbound msg"
exten => s,6,Background(outboundmsgs/how_to_ack) ; "Press 1 to replay or 2 to acknowledge receiving this message"
exten => 1,1,Goto(s,5) ; replay message
exten => 2,1,Goto(msgack,s,1) ; acknowledge message
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup

exten => s,1,Background(silence/1)
exten => s,n,ControlPlayback(outboundmsgs/thankyou)
exten => s,n,Set(filename=${callfile_name}${STRFTIME(${EPOCH},GMT-8,%m%d%y-%H%M)}.wav)
exten => s,n,Record(/var/${filename},0,5,xk)
exten => s,n,Hangup
exten => h,1,System(/opt/scripts/ /var/tmp/${filename} {sendtoemail})

The script will not stop and record the name of the person called and email the file. It does send a file, but it plays “thankyou” and then says “Goodbye”

I just can not see the error of my ways.