fixed a bug that improved performance significantly