Fix undefined local variable 'name'