initial refactoring using factory patter (#91)