Updating plain text answer and refactoring some code.