remove duplicate code for generating icon code