refactored to make density objects, documentation