add check to make sure operand of sqrt is non negative