minor changes to density calculation