adapted to modern functions and bootstrapping