fixed some bugs and some improments