refactored shit ton of code