all that work and it turned out it didn't even work right, so here are the bug fixes