fixed a bug introduced while refactoring.