fix errors and bugs