fixing bugs and making some changes