new version

complete rewrite