merge with jlee and special case when the maxWallNum is larger than 4