utility routine written by Doug