fixing bugs and revision