added callback, speed improvements