fix some bugs introduced before