refactoring, bugfixing