modified code to run in splitjs or non-splitjs mode