extract fileExists function to use as a filter