docs update and code optimization