fixed a few bugs in my code