fixed bug in refactor