Refactored code - might transition to a factory design pattern soon