fixed 'list out of index range' error