finished rewriting code, now testing