Refactor square root