adding pausing function