Small fix and refactoring