complete rewrite of everyting