fixed some bugs
merged