chunk method for splitting arrays into chunks of specified length