A data dependent approach to density estimation