Yea, well quick fix is changing

if as_array.include?(elename.name)
to
if item && elename && as_array.include?(elename.name)


-- 
Marcin Raczkowski
---
Friends teach what you should know
Enemies Teach what you have to know