use function pause and resume while handling interruption