Update 3

major code refactoring