fix bug in sqrt implementation