changed order of operations

(cherry picked from commit 09f40255d689f2b5dd4533c0552ae72861109d76)
Merge pull request #868 from claco/v4.2.2rc

changed order of operations