refactor places to be easier to read and more efficient