[refac] use recursive functionconstructor