fix errors and exceptions