Here's the main little piece of code. I need to optimize it.