add basic downsampling function + fix build