almost done re-writing