fixup and refactoring