Final version for the problem