added guard to stopScanning onPause