Using regular expression to test for data attribute and also other improvements.