working on speeding up the KDE algor