ugly ugly implementation of letfn