this is nasty; can we get rid of it in some way? what about a helper function?