updated for speed improvements