fixing bugs and typo