Fixed the bug with the final solution