Fixed error caused by extreme differences in density