refactored to use factory method instead of objects