docstring and removed unused code.
added execution function, for easier acces in other files.
refactor to do things in the right order
refactor for easier running and execution from other files.