rename function to avoid conflict, and set empty dirs to prevent possible asort() error