Refactored code

Simple refactoring of the code is implemented;