added dist function