Add conditional checks

Fixes #9. Removed concatenation on $attributes[‘id’] and added
conditional statements around each element where an ID needed to be
added.