added regex check for trailing slashes