#212 Refactored and code style improved