complete rewrite..basically