added loop for directory