Fix issue where variable is used before it is declared
Merge pull request #3084 from mkoistinen/fix_cms_check

Fix issue where variable is used before it is declared