fix open directory 2 times