complete rewrite......