Using an IIFE to avoid passing a function as an argument