first commit

work in progress(refactoring):
introduces closure into the code style
separates code into functions