Update 3 - refactoring, code optimization