Refactor constructor
Extract some code from the render method