Fixed #52: error when list is empty

Just added a check if the list item is not null.