safely handle filepaths