Fix: put cache variable in closure