maybe we could initialize data and eventData with an empty array when they are null, and use the same code for all cases instead of dealing with blocks of if (data == null) else ...