optimization of searching of head number (list --> dictionary)