refactored splitting functionality