modified sqrt algorithm