refactor sqrt function to take advantage of scoping