Fixed infinite loop when there is no sqare root