remove a few bits and refactor