Added a necessary null check