escaping slashes and added optional group support