split up replaceAttr() to soothe scrutinizer