improved speed
corrected