moved sampling to the top

Speeds up the tm_map operations