Fixed undefined names variable error

Fixes undefined 'names' variable