fixed a few bits of code