move common stuff out of the items template
update number of items remaining