Implementing the solution