added optional email function