fixed some bugs and added new functionality