Implemented importance resampling