working split script
refactor