bit refactoring and fixing