updated final solution