modified to support subdir