Here we also have 3-levels of if,
but it seems line 141 and 144 both use handoverType to check,
maybe we could have one if-block less.