refactor to move split into a func