completed first draft attempt
refactoring solution to organize code and functionalities