fix some bug form Frederic feedback