Having this error in dist function