issue #1. fixed some bugs.