Fixed Issue #2. Credit: MartyMacGyver

Fixed Issue #2, a bug spotted by MartyMacGyver. The solution was also
proposed by him. Thank you for the contribution.