fixed integration problem with density. fix gcc error with variable capture