dirty but works -- lots of cleanup to do