renamed flat_density to sample_density, added area function