added check for open files