looks like lots of duplicated code to me.