Faster code

Found the part of the code that was slowing it down.