Fix the sampling code for gup