Simplify code for toggling expand/contract icons.