added option to return integrated density