fixed array out-of-bounds error and working through findBestSplit function