Fix a little bugs

The code didn't work on my computer. I found some bugs and fixed it.