Make density interactive
Improve function for calculation items count