add fix for changing dict while iterate the same time
add dir checks with exceptions