Made some changes from previous code