bugfix refactor