Fixed error

correctly used the append function in the loop