declare `fn` before it's needed