Possible fix for NPE

Thanks to Mahdi786 for this!

Signed-off-by: Chintan Shah <cgintan1998@gmail.com>