phase2: cleaned codebase
changed code structure