bean factory refactor