Updated code to match original release

Some changes must have taken place during the initial post that broke
the code somewhere around line 46