fixing bugs causing asserting failure