improve performance. fixed bugs