use @jugglinmike's variant of detecting elements

previous solution didn't recognize arrays