refactor render and to_s to prevent duplicated work