reworked Pause/Resume code