bug fix on casting of double