filenameAlreadyExists() refactoring