updated and split code