Added error check on takePicture also