regex
minor syntax fix
add more error handing