fix #11261: improved logic for inserting measures
code cleanup of last commit
Merge pull request #297 from danielgarthur/11261-insertmeasures

fix #11261: improved logic for inserting measures