bugfix in factory method