Refactor replace dict with list