Fixed bug on the list append function