updated captureView function