working prototype 1.3, code refactoring