Issue 398

Wanted to fix the issue, but also wanted to make the code a little easier to understand
Good call!