trying to speed it up, but failing.