fix sometimes referencing nil values
Merge pull request #620 from sidschingis/master

fix sometimes referencing nil values