almost done; one more bug to fix