glob_trial code from Lap, edited, read and tested.