Change captureImage() to synchronized