correct stopFlag and turnFlag to be set correctly