Refactored towards issue #4