should've made a new CPI branch, code is a mess right now, see previous commit for well documneted/formed version