I'm going to rewrite this in rust when I learn it