update code, fix errors