Someone else might have deleted f in the meantime - so need to check f isn't NULL.