fixed global variable and consolidated unpause event handler