fixed problem with subsampling. please check if this works fine!