cleaned up a few things, this should be a working version