[Refactor] change for iterative way of returning values