HUGE CODE REVAMP