initial revision. seems to work well enough for my purposes.