Update main.cpp

Improved the performance a little bit.