Refactor sampleThickness