add proper regex
added proper regex for check function
add comment for changed code