Added check for existing files