Fix bug with refactor