fixed a few errors in the code