Refactored pull request #169 into new and clean commit