optimized main loop

corrected problem with rgb values rendering incorrectly