changed example from using a closure