remove duplicate code in toThunk