add factory pattern and code to interface