Cleaned up the splitArray method