fixed some bugs in the run mode