optimize list code