function to chunk input and inset