Code refactoring for PR #160