added result check against undefined case