some improvements in the code, such as limit on the number of splits