first working version, should be bugfree and 100% compatible with master branch