more efficient error code checking
Merge pull request #79 from joshowen/patch-1

more efficient error code checking