Works properly for all directories