implemeneting dim estimation