added delta function and some minor tweaks