clean up slice handling code