added square root check