Fixed errors in previous refactoring