Almost done, just need to do some testing and tweaking