fixed resample bug when not square