ticket#8 - done. Code refactored