Fixed bug in previous refactoring