added some features, fixed some bugs