local variable 'collection_data' referenced before assignment