Towards an accurate kernel density function