optimized to scan list of pairs of gls only once
Merge pull request #3 from mioalter/tempHW8

optimized to scan list of pairs of gls only once