added functions from steve losh