m/directory: completed function and validated as working faster