Store state in closure