rename function, add 'mode' parameter for extending functionality later