Fixed the bug for the previous program.