Code refactoring
Added documentation