small refactoring + bugfix