added check if path is a file