fixed bug on refactor