almost finish functions/speed; no tests yet