fixed a lot of code