changed second half of fxn to work with scanimage 3