refactoring; bugfix