updated for some bugs