Fixed bug resulted from the refactoring.