Fixed bug in accessing density