if-else conditional on prevItem.isDefined is more readable if we skip the NOT operators