fixed bug from the refactoring