added file_exists check when looping through local files