add {name} and fix logic