fixed it, this untested code is going to kill me