Updated sample with closures