added dist and math