Added a new way to sample points and some util functins