IT FUCKING WORKS HOLY CRAP I'VE SPENT 4 HOURS ON THIS PROBLEM