Handled the pause and resume events