Added an imperative solution