function-ize sqrt controller