refactoring tons of confusing code