Added fail-safe code for non-existing folders