+ code refactoring (untested)