Update to remove duplicate code. 

Untested.
Merge pull request #1 from michaelw90/patch-1

Update to remove duplicate code.