bugfix, and do lots of improvement