Fixed logic ordering to prevent AttributeError
Merge pull request #1 from shaunduncan/master

Fixed logic ordering to prevent AttributeError