Changed code to make subnet thinning work