Refactored code and added Memorizer