Game engine dev - added a null check