fixed a few errors and bugs