fixed sometimes referencing nil values
Merge pull request #617 from sidschingis/master

fixed sometimes referencing nil values