implemented and tested factory class