Fix: global name 'data' is not defined