added some features and fixed some bugs