some bugs corrected