some fixes
more idiomatic
DRY: use a variable
remove regexp anchor --- more robust
Merge pull request #1 from zmughal/master

some fixes