Improve efficiency.

Same change as my other pull request. Please view it for more information.
Merge pull request #2 from imduffy15/patch-2

Improve efficiency.