Fixed a potential math domain bug