Renamed function
Refactored factory into closure and don't mutate state