Fix the AttributeError

Fixes #512.