Refactored to remove imperative functions, now they are at the correct place as factory methods