update and fix bugs