Merge pull request #737 from wicaksono/master

Use `hasAttribute()` instead to avoid code duplication