A few attempts and making this faster.