fix errors and code style