fixing some bugs and adding some features