last commit, finished up functionality
refactored and commented a lot