Added a bunch of the logic

not even close to being done, might be runnable later tonight