some further refactoring/trsting and adding factory