Issue #7 - Simplified the code a bit and removed some redundancy.