refactored a shit ton of code