fixed a small optimization bug