improve dict regex
improve formatting