refine square root implementation