helper routines written, not tested