fixed some bugs related to previous commit