add density computation, but there are bugs