small fix and refactoring