Refactored the code a tad. Thanks jgable.