Added global variables and decode command function