modify code for multiresolution