newish code need big cleanup